{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "排序前 [2, 6, 3, 0, 56, 98, 23, 1]\n"
     ]
    }
   ],
   "source": [
    "arr = [2,6,3,0,56,98,23,1]\n",
    "print('排序前', arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_len = len(arr)\n",
    "for i in range(arr_len):\n",
    "    for j in range(0, arr_len-i-1):\n",
    "        if arr[j] > arr[j+1]:\n",
    "            arr[j], arr[j+1] = arr[j+1], arr[j]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "排序后 [0, 1, 2, 3, 6, 23, 56, 98]\n"
     ]
    }
   ],
   "source": [
    "print('排序后', arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
